<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title></title>
        <link href="css/paginaPronta.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body onload="document.getElementById('form1:codigo').focus()" >
        <ui:composition template="#{mudarTemplateBean.template}">
            <ui:define name="centro">

                <div id="divCentro">
                    <p:messages globalOnly="true" showDetail="true" redisplay="left" />
                    <p:panel header="#{mens.CADASTRO_DE_MATERIA_PRIMA}" visible="true" toggleable="true" styleClass="painelCentral" >
                        <h:form id="form1">
                            <h:inputHidden value="#{manterMateriaPrimaBean.materiaprima.id}"/>
                            <h:panelGrid  columns="3" >

                                <h:outputText value="#{mens.NOME}" />
                                <p:inputText id="nome" value="#{manterMateriaPrimaBean.materiaprima.nome}" required="true" size="30" />
                                <p:message for="nome"/>

                                <h:outputText value="#{mens.CODIGO}" />
                                <p:inputText id="codigo" value="#{manterMateriaPrimaBean.codigo}" required="true" size="30" >
                                    <f:validateRegex pattern="[0-9_]*"/>
                                    <f:validateLength  maximum="10" /></p:inputText>
                                <p:message for="codigo"/>

                                <h:outputText value="#{mens.PRECO}" />
                                <p:inputText id="preco" required="true" value="#{manterMateriaPrimaBean.preco}" size="30"  >
                                    <f:validateRegex pattern="[0-9_.]*"/>
                                    <f:validateLength  maximum="7" /></p:inputText>
                                <p:message for="preco"/>

                                <h:outputText id="fornecedor" value="#{mens.FORNECEDOR}"/>
                                <p:inputText/><!--  required="true" size="30" /-->
                                <p:message for="fornecedor"/>

                            </h:panelGrid>

                            <p:separator />
                            <h:panelGrid columns="3">
                                <p:commandButton ajax="false" value="#{mens.INSERIR}" action="#{manterMateriaPrimaBean.create}"  />
                                <p:commandButton ajax="false" value="#{mens.ALTERAR}" action="#{manterMateriaPrimaBean.edit}" disabled="#{manterMateriaPrimaBean.naoSelecionouMateriaPrima}"/>
                                <p:commandButton ajax="false" value="#{mens.EXCLUIR}" action="#{manterMateriaPrimaBean.destroy}" disabled="#{manterMateriaPrimaBean.naoSelecionouMateriaPrima}"/>
                            </h:panelGrid>
                        </h:form>

                        <h:form>
                            <h:panelGrid>
                                <p:panel header="#{mens.PESQUISAR_POR}" >
                                    <h:selectOneMenu >
                                        <f:selectItem itemLabel=""/>
                                        <f:selectItem itemLabel="Nome"/>
                                        <f:selectItem itemLabel="Codigo"/>
                                        <f:selectItem itemLabel="Fornecedor"/>
                                    </h:selectOneMenu>
                                    <p:inputText  style="margin-left: 5px"/>
                                    <p:commandButton  value="#{mens.PESQUISAR}" action="#{manterMateriaPrimaBean.findMateriaprimaEntities}" image="url(../img/pesquisa2.png)" ajax="false" />
                                </p:panel>
                            </h:panelGrid>
                            <p:panel header="#{mens.PAINEL_DE_PESQUISA}" visible="true" toggleable="true" styleClass="painelCentral">
                                <p:dataTable paginator="true" rows="4" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} " rowsPerPageTemplate="5" emptyMessage="#{mens.TABELA_VAZIA}" value="#{manterMateriaPrimaBean.materiaPrimas}" var="m" style="width:580px " rendered="#{manterMateriaPrimaBean.exibeTabela}">
                                    <p:column style="width: 200px">
                                        <f:facet name="header">#{mens.CODIGO}</f:facet>

                                        <h:commandLink style="color: maroon; font-weight: bolder" value="#{m.codigo}" action="paginaManterMateriaPrimaTeste.xhtml">
                                            <f:setPropertyActionListener value="#{m.codigo}" target="#{manterMateriaPrimaBean.codigo}"/>
                                            <f:setPropertyActionListener value="#{m.nome}" target="#{manterMateriaPrimaBean.materiaprima.nome}"/>
                                            <f:setPropertyActionListener value="#{m.preco}" target="#{manterMateriaPrimaBean.preco}"/>
                                            <f:setPropertyActionListener value="#{m.id}" target="#{manterMateriaPrimaBean.materiaprima.id}"/>
                                            <f:setPropertyActionListener value="false" target="#{manterMateriaPrimaBean.naoSelecionouMateriaPrima}"/>
                                        </h:commandLink>


                                    </p:column>
                                    <p:column style="width: 220px">
                                        <f:facet name="header">#{mens.NOME}</f:facet>
                                        <h:outputText value="#{m.nome}"/>
                                    </p:column>
                                    <p:column style="width: 200px">
                                        <f:facet name="header">#{mens.PRECO}</f:facet>
                                        <h:outputText value="#{m.preco}"/>
                                    </p:column>
                                </p:dataTable>
                            </p:panel>



                        </h:form>

                    </p:panel>
                </div>
            </ui:define>
        </ui:composition>



    </h:body>
</html>
